var http=require("http");
var fs=require("fs");
var path=require("path");
var data1;
var filePath=path.join(__dirname,"/"+process.argv[2]);
if(process.argv[2]){
    fs.access(filePath,(err)=>{
        console.log(err);
    });
}else{
    filePath=path.join(__dirname,"/fileReader1.js");
}

fs.readFile(filePath,(err,data)=>{
    data1=data.toString('utf8');
    if(err){
        console.log("出错啦！");
    }else{
        http.createServer((req,res)=>{
            res.writeHead(200,{"Content-Type":"text/html"});
            res.write("<!DOCTYPE html><html>"+
            "<head></head><body style='background:white'>"+
                
            "<div>"+data1+"</div>"
                
                +"</body></html>"    );
            res.end();
        }).listen(8081);       
        
    }
})
console.log("server is listening 8081");